package com.fasteat.menu.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.fasteat.menu.entity.Menu;
import com.fasteat.menu.entity.vo.MenuMessageVo;
import com.fasteat.menu.entity.vo.MenuPraiseVo;
import com.fasteat.menu.entity.vo.MenuVo;
import com.fasteat.menu.entity.vo.SimpleMenuVo;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 * @author run
 * @since 2021-01-19
 */
public interface MenuMapper extends BaseMapper<Menu> {

    public List<SimpleMenuVo> getSimpleMenuVosOfIds(List<String> menuIds);

    public List<String> getTagsOfMenus(List<String> menuIds);

    @Select("SELECT menu_tag FROM t_menu_info ORDER BY menu_view + menu_collect + menu_praise + menu_comment DESC LIMIT 0,10")
    public List<String> getHotTags();

    @Select("SELECT menu_title FROM t_menu_info WHERE is_deleted = 0")
    public List<String> getTitle();

    @Update("UPDATE t_menu_info SET menu_context = #{menuContext} WHERE menu_title = #{menuTitle}")
    public void setMenuContextByTitle(String menuContext,String menuTitle);

    @Select("SELECT id, menu_praise FROM t_menu_info WHERE author_id = #{userId}")
    public List<MenuPraiseVo> getUserPraise(String userId);

    @Select("SELECT id, menu_praise, menu_view, menu_collect, menu_comment FROM t_menu_info WHERE id = #{menuId}")
    public MenuMessageVo getMenuMessage(String menuId);

    public List<MenuVo> getMenuVosOfIds(List<String> menuIds);

    public List<MenuVo> getDefaultRecommendMenu(Integer page, Integer size);

}
